using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace Player
{
    /// <summary>
    /// generate by msg tool
    /// 玩家信息
    /// </summary>
	public class PlayerInfo : Dto
	{
		//玩家id
		public long id;
		//微信openId
		public String openId;
		//微信昵称
		public String nickName;
		//性别
		public int sex;
		//头像地址
		public String icon;
		//国家
		public String country;
		//省
		public String province;
		//市
		public String city;
		//机器码
		public String mac;
		//ip
		public String ip;
		//房间id(0:代表没有在房间中)
		public int roomId;
		//砖石数量
		public long diamond;

        public PlayerInfo() { }

        public PlayerInfo(long id, String openId, String nickName, int sex, String icon, String country, String province, String city, String mac, String ip, int roomId, long diamond)
        {
            this.id = id;
            this.openId = openId;
            this.nickName = nickName;
            this.sex = sex;
            this.icon = icon;
            this.country = country;
            this.province = province;
            this.city = city;
            this.mac = mac;
            this.ip = ip;
            this.roomId = roomId;
            this.diamond = diamond;
        }

        
		public void write(object obj)
		{
			ByteBuffer b = obj as ByteBuffer;
			b.PushLong(id);
			b.PushString(openId);
			b.PushString(nickName);
			b.PushInt(sex);
			b.PushString(icon);
			b.PushString(country);
			b.PushString(province);
			b.PushString(city);
			b.PushString(mac);
			b.PushString(ip);
			b.PushInt(roomId);
			b.PushLong(diamond);
			
		}

	    public void read(object obj)
		{
		    MyConverter b = obj as MyConverter;
			id = b.toInt64();
			openId = b.toString();
			nickName = b.toString();
			sex = b.toInt32();
			icon = b.toString();
			country = b.toString();
			province = b.toString();
			city = b.toString();
			mac = b.toString();
			ip = b.toString();
			roomId = b.toInt32();
			diamond = b.toInt64();
			
		}

	}
}